package com.fw.ui.util.validator;

import com.vaadin.data.Validator;

public class RequireFieldValidator implements Validator {

    private static final long serialVersionUID = 1L;

    private String message;
    
    public RequireFieldValidator(String message) {
	this.message = message;
    }

    @Override
    public void validate(Object value) throws InvalidValueException {
	if (value == null) {
	    throw new InvalidValueException(message);
	}
	if (value.toString().trim().length() == 0) {
	    throw new InvalidValueException(message);
	}
    }

}
